package com.hzcx.app.simplechat.ui.setting.adapter;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.hyphenate.chat.EMImageMessageBody;
import com.hyphenate.chat.EMMessage;
import com.hzcx.app.simplechat.R;
import com.hzcx.app.simplechat.ui.setting.bean.ChatSearchImgBean;
import com.hzcx.app.simplechat.ui.setting.bean.ChatSearchImgSubBean;
import com.hzcx.app.simplechat.util.glide.GlideUtils;

import java.util.List;

public class ChatSearchImgSubAdapter extends BaseQuickAdapter<ChatSearchImgSubBean, BaseViewHolder> {

    private int tag;

    public ChatSearchImgSubAdapter(@Nullable List<ChatSearchImgSubBean> data, int tag) {
        super(R.layout.rv_item_chat_search_img_sub, data);
        this.tag = tag;
    }

    @Override
    protected void convert(BaseViewHolder helper, ChatSearchImgSubBean item) {
        EMMessage message = item.getMessage();
        EMImageMessageBody imgBody = (EMImageMessageBody) message.getBody();
        String uri = imgBody.getRemoteUrl();
        GlideUtils.loadImgAsCenter(mContext, uri, helper.getView(R.id.iv_img));

        if (item.isSelect()) {
            helper.setImageResource(R.id.iv_check_box, R.mipmap.ic_icon_check_select);
        } else {
            helper.setImageResource(R.id.iv_check_box, R.mipmap.ic_icon_check_normal);
        }

        if (tag == 1) {
            helper.setVisible(R.id.iv_check_box, true);
        } else {
            helper.setVisible(R.id.iv_check_box, false);
        }
    }
}
